package com.rh.number.Converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.data.CellData;

import java.text.SimpleDateFormat;

public class SqlDateConverter implements Converter<java.sql.Date> {
    @Override
    public Class<?> supportJavaTypeKey() {
        return java.sql.Date.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    public WriteCellData<?> convertToExcelData(java.sql.Date value) {
        // 将 java.sql.Date 转换为字符串（例如 "yyyy-MM-dd"）
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return new WriteCellData<>(sdf.format(value));
    }
}